Make tsc_mode=3 (pvrdtscp) work correctly.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Dec 2009 07:48:45 +0000 (07:48 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Dec 2009 07:48:45 +0000 (07:48 +0000)
commit80bae1b6dc28b342c30228795ee48db1a79641cb
tree2ab5f0838c4765e8caec3d0dc1869d0ba2504810
parent7b4effff892d18d8e83563a7e6868bb7c7749fc5
Make tsc_mode=3 (pvrdtscp) work correctly.

Initial tsc_mode patch contained a rough cut at pvrdtscp mode.  This
patch gets it working correctly.  For the record, pvrdtscp mode allows
an application to obtain information from Xen to descale/de-offset
a physical tsc value to obtain "nsec since VM start".  Though the
raw tsc value may change across migration due to different Hz rates
and different start times of different physical machines, applying
the pvrdtscp algorithm to a raw tsc value guarantees that the result
will always be both a fixed known rate (nanoseconds) and monotonically
increasing.  BUT, pvrdtscp will only be fast on physical machines that
support the rdtscp instruction AND on which tsc is "safe"; on other
machines both the rdtsc and rdtscp instructions will be emulated.
Also note that when tsc_mode=3 is enabled, tsc-sensitive applications
that do NOT implement the pvrdtscp algorithm will behave incorrectly.
So, tsc_mode=3 should only be used when all apps are either
tsc-resilient
or pvrdtscp-modified, and only has a performance advantage on very
recent generation processors.

Signed-off-by: Dan Magenheiemer <dan.magenheimer@oracle.com>
xen/arch/x86/time.c
xen/arch/x86/traps.c